from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field
from pydantic.alias_generators import to_camel
from typing import Optional
from module_admin.annotation.pydantic_annotation import as_query




class TaskModel(BaseModel):
    """
    种植任务明细表对应pydantic模型
    """
    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    task_id: Optional[int] = Field(default=None, description='任务Id')
    task_name: Optional[str] = Field(default=None, description='任务名称')
    task_leader_id: Optional[int] = Field(default=None, description='责任人Id')
    task_type: Optional[str] = Field(default=None, description='任务类型')
    task_leader: Optional[str] = Field(default=None, description='责任人')
    scheduled_start_time: Optional[datetime] = Field(default=None, description='计划开始时间')
    scheduled_end_time: Optional[datetime] = Field(default=None, description='计划结束时间')
    actual_start_time: Optional[datetime] = Field(default=None, description='实际开始时间')
    actual_end_time: Optional[datetime] = Field(default=None, description='实际结束时间')
    task_description: Optional[str] = Field(default=None, description='任务详情')
    plant_plot_id: Optional[int] = Field(default=None, description='关联地块id')
    plant_plot_name: Optional[str] = Field(default=None, description='关联地块')
    planter_id: Optional[int] = Field(default=None, description='种植主体Id')
    planter_name: Optional[str] = Field(default=None, description='种植主体')
    product_area_id: Optional[int] = Field(default=None, description='产区id')
    product_area_name: Optional[str] = Field(default=None, description='产区')
    year: Optional[int] = Field(default=None, description='数据年份')
    is_ontime: Optional[int] = Field(default=None, description='是否按时完成')






class TaskQueryModel(TaskModel):
    """
    种植任务明细不分页查询模型
    """
    begin_scheduled_start_time: Optional[str] = Field(default=None, description='开始计划开始时间')
    end_scheduled_start_time: Optional[str] = Field(default=None, description='结束计划开始时间')
    begin_actual_start_time: Optional[str] = Field(default=None, description='开始实际开始时间')
    end_actual_start_time: Optional[str] = Field(default=None, description='结束实际开始时间')


@as_query
class TaskPageQueryModel(TaskQueryModel):
    """
    种植任务明细分页查询模型
    """

    page_num: int = Field(default=1, description='当前页码')
    page_size: int = Field(default=10, description='每页记录数')


class DeleteTaskModel(BaseModel):
    """
    删除种植任务明细模型
    """

    model_config = ConfigDict(alias_generator=to_camel)

    task_ids: str = Field(description='需要删除的任务Id')
